package io.renren.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.dao.EslRefreshLogDao;
import io.renren.entity.EslRefreshLogEntity;
import io.renren.service.EslRefreshLogService;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("eslRefreshLogService")
public class EslRefreshLogServiceImpl extends ServiceImpl<EslRefreshLogDao, EslRefreshLogEntity> implements EslRefreshLogService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        IPage<EslRefreshLogEntity> page = this.page(
                new Query<EslRefreshLogEntity>().getPage(params),
                new QueryWrapper<EslRefreshLogEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public EslRefreshLogEntity queryBySid(String sid) {

        return baseMapper.selectOne(new QueryWrapper<EslRefreshLogEntity>()
                .eq("sid", sid)
                .orderByDesc("id")
                .last("limit 1")
        );
    }

    @Override
    public EslRefreshLogEntity queryByEslId(String eslId) {

        return baseMapper.selectOne(new QueryWrapper<EslRefreshLogEntity>()
                .eq("esl_id", eslId)
                .orderByDesc("id")
                .last("limit 1")
        );
    }


}
